<template>
  <el-dropdown trigger="click" @command="commandFn">
    <div>
      <svg-icon style="color:#fff;font-size:20px" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item
        :disabled="$i18n.locale === 'zh'"
        command="zh"
      >中文</el-dropdown-item>
      <el-dropdown-item
        :disabled="$i18n.locale === 'en'"
        command="en"
      >english</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  name: 'Lang',
  methods: {
    commandFn(command) {
      console.log('执行了')
      // 修改i18n的语言环境
      this.$i18n.locale = command
      Cookie.set('language', command)
    }
  }
}
</script>
